package com.coda.service.impl;

import com.coda.mapper.CommentMapper;
import com.coda.pojo.Comment;
import com.coda.pojo.CommentReply;
import com.coda.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户评论业务层
 */
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    /**
     * 获取所有评论
     * @return
     */
    @Override
    public List<Comment> getCommentAll(String orderType) {
        return commentMapper.getCommentAll(orderType);
    }

    /**
     * 点赞
     * @return
     */
    @Override
    public int upvote(Integer id) {
        return commentMapper.upvote(id);
    }

    /**
     * 发表评论
     * @param comment
     * @return
     */
    @Override
    public int addComment(Comment comment) {
        return commentMapper.insert(comment);
    }
}
